package subject.tengxun.middle;

/**
 * 功能：
 * 作者：yedou
 * 日期：2025/3/14 13:54
 */
public class maxArea {
    public static void main(String[] args) {
        int[] height = {1, 8, 6, 2, 5, 4, 8, 3, 7};
        int area = 0;
        int left = 0;
        int right = height.length - 1;
        while (left < right) {
            int areaWater = (right - left) * Math.min(height[left], height[right]);
            if (areaWater > area) {
                area = areaWater;
            }
            if (height[left] < height[right]) {
                left = left + 1;
            } else {
                right = right - 1;
            }
        }
        System.out.println("最大的容器水:" + area);
    }
}